import { createRouter, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        redirect: '/home'//重定向
    },
    // home
    {
        path: '/home',
        name:'home',
        alias: '/root',//路由别名 用于地址栏，/home可以匹配，/root也可以匹配
        meta: {
            name: "首页",
        },
        component:() =>import(/* webpackChunkName: 'home' */'../views/Home/Home.vue'),
    },
    // 信息
    {
        path: '/message',
        name:'message',
        alias: '/message',//路由别名 用于地址栏，/home可以匹配，/root也可以匹配
        meta: {
            name: "信息",
        },
        component:() =>import(/* webpackChunkName: 'home' */'../views/Message/Message.vue'),
    },
     // 用户
     {
        path: '/user',
        name:'user',
        alias: '/user',//路由别名 用于地址栏，/home可以匹配，/root也可以匹配
        meta: {
            name: "个人中心",
        },
        component:() =>import(/* webpackChunkName: 'home' */'../views/User/user.vue'),
    },
    // 设置
    {
        path: '/setting',
        name:'setting',
        alias: '/setting',//路由别名 用于地址栏，/home可以匹配，/root也可以匹配
        meta: {
            name: "设置",
        },
        component:() =>import(/* webpackChunkName: 'home' */'../views/Setting/Setting.vue'),
    },
    // 设置
    {
        path: '/login',
        name:'login',
        alias: '/login',//路由别名 用于地址栏，/home可以匹配，/root也可以匹配
        meta: {
            name: "登录/注册",
        },
        component:() =>import(/* webpackChunkName: 'home' */'../views/LoginAndRegister/LoginAndRegister.vue'),
    },
    // 404页面
    {
        path: '/404',
        name:'404',
        meta: {
            name: "404",
        },
        component: ()=>import('../views/NotFound.vue')
    },
    // 错误路径
    {
        path: '/:pathMatch(.*)*',//匹配所有路径
        redirect: '/404'
    }

]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
